package com.youlu.campus.admin.leads.controller;

import com.youlu.campus.admin.leads.dto.SalesLeadsRequst;
import com.youlu.campus.admin.leads.dto.SalesLeadsResponse;
import com.youlu.campus.admin.leads.entity.SalesLeads;
import com.youlu.campus.admin.leads.service.SalesLeadsService;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.HashMap;

/**
 * 成长API
 *
 */
@RestController
public class SalesLeadsController {
    @Autowired
    private SalesLeadsService salesLeadsService;

    /**
     * 个人学习计划
     * @param request
     * @return
     */
    @PostMapping("/sales-leads/list")
    public QResult listPages(@RequestBody @Valid SalesLeadsRequst request) {

        return QResult.success(salesLeadsService.list(request));

    }

    /**
     * 个人学习计划修改跟进记录
     * @param datas
     * @return
     */
    @PostMapping("/sales-leads/update")
    public QResult updateComment(@RequestBody @Valid @NotNull HashMap<String, Object> datas) {
        SalesLeads s = new SalesLeads();
        if (datas.containsKey("id")) {
            s.setId((String) datas.get("id"));
        }
        if (datas.containsKey("comment")) {
            s.setComment((String) datas.get("comment"));
        }
        return QResult.success(salesLeadsService.update(s));

    }

}
